package com.milepost.workflow.flowinsttask.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.milepost.workflow.common.enums.TaskTypeEnum;
import com.milepost.workflow.flowdeftask.entity.FlowDefTaskEntity;
import com.milepost.workflow.flowinsttaskapp.entity.FlowInstTaskAppEntity;
import lombok.Data;

import java.util.Date;
import java.util.List;

/**
 * @author huarf
 * @Description
 * @create 2022-03-27 17:24
 */
@Data
@TableName("flow_inst_task")
public class FlowInstTaskEntity {

    private String id;
    private String flowInstId;
    private String name;
    private String des;
    private String type;
    private String assignees;
    @TableField(exist = false)
    private String assigneesName;
    private Integer orderNum;
    private Date startTime;
    private Date endTime;
    private Integer pass;
    @TableField(exist = false)
    private List<FlowInstTaskAppEntity> flowInstTaskAppEntityList;

    public FlowInstTaskEntity() {

    }

    public FlowInstTaskEntity(FlowDefTaskEntity flowDefTaskEntity) {

        this.name = flowDefTaskEntity.getName();
        this.des = flowDefTaskEntity.getDes();
        this.type = flowDefTaskEntity.getType();
        if (!this.type.equalsIgnoreCase(TaskTypeEnum.POINT_TASK.getType())
                && !this.type.equalsIgnoreCase(TaskTypeEnum.START.getType())
                && !this.type.equalsIgnoreCase(TaskTypeEnum.END.getType())) {
            this.assignees = flowDefTaskEntity.getAssignees();
        }
        this.orderNum = flowDefTaskEntity.getOrderNum();
    }

}
